package com.doodod.common.utils;

import java.io.*;

/**
 * Created by ydw on 15/6/18.
 */
public class FileUtil {

    /**
     * 向文件写入指定的行
     * @param filePath
     * @param line
     */
    public static void write(String filePath, String line){
        try {
            File file = new File(filePath);
            if (!file.exists()) {
                file.createNewFile();
                file = new File(filePath);
            }
            BufferedWriter writer = new BufferedWriter(new FileWriter(file, true));
            writer.write(line);
            writer.newLine();
            writer.close();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    /**
     * 删除文件中的指定行
     * @param filePath
     * @param line
     */
    public static void delete(String filePath, String line){

    }

    public static void main(String[] args){
        FileUtil.write("/tmp/test", "dasda");
    }

}
